/** CS2340 Spring 2011 Project
 *  Team: 40 Jiggawatt Hard Driver
 *  Suk Hwan Hong
 *  Rhys Saraceni
 *  Travis Cooper
 *  Luke Stubb
 *
 * @author 40 Jiggawatt Hard Driver
 * @version 1.0 
 */

package edu.gatech.jiggawatt.office.model;

import java.io.Serializable;
import java.util.Calendar;

/**
 * Represents yearly schedule
 * @author 40 Jiggawatt Hard Driver
 * @version 1.0
 *
 */
public class YearlySchedule implements Serializable // $codepro.audit.disable declareDefaultConstructors
{
	private int year;
	
	MonthlySchedule[] months;
	
	/**
	 * Creates yearly schedule
	 * @param year
	 */
	public YearlySchedule(int year)
	{
		this.year = year;
		months = new MonthlySchedule[12]; // $codepro.audit.disable numericLiterals
		Calendar calendar = Calendar.getInstance();
        
		for (int i = 0; i < 12; i++) // $codepro.audit.disable numericLiterals
		{
			calendar.set(year, i, 1);
			int numDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); // $codepro.audit.disable variableDeclaredInLoop
			months[i] = new MonthlySchedule(year, i+1, numDays); 
		}
	}
	
	/**
	 * gets monthly schedule
	 * @param month
	 * @return monthly schedule
	 */
	public MonthlySchedule getMonthlySchedule(int month)
	{
		return months[month-1];
	}
	
	/**
	 * gets list of monthly schedules
	 * @return list of monthly schedules
	 */
	public MonthlySchedule[] getMonthlySchedules()
	{
		return months;
	}
	
	/**
	 * returns string format of yearly schedule
	 * @return string format of yearly schedule
	 */
	public String toString()
	{
		return year + "";
	}
	
	/**
	 * gets year
	 * @return year
	 */
	public int getYear()
	{
		return year;
	}
}
